
#ifndef _CARD_COMMAND_H__
#define _CARD_COMMAND_H__

void Card_SetupKey(uint8_t card, uint8_t uid[4]);
void Card_EncryptMode(uint8_t card, uint8_t mode);

//选文件
int Card_SelectFileById(uint8_t card, uint16_t fid);
//取随机数
int Card_GetChallenge(uint8_t card, uint8_t clen, uint8_t random[]);
//外部认证
int Card_ExternalAuth(uint8_t card, uint8_t keyId, uint8_t key[], uint8_t klen, uint8_t random[], uint8_t rlen);
int Card_RawExternalAuth(uint8_t card, uint8_t keyId, uint8_t random[], uint8_t rlen);

//内部认证
int Card_InternalAuth(uint8_t card, uint8_t keyId, uint8_t key[], uint8_t klen, uint8_t authData[], uint8_t len);
int Card_RawInternalAuth(uint8_t card, uint8_t keyId, uint8_t authData[], uint8_t len, uint8_t resp[], uint16_t*rlen);

//读二进制文件
int Card_ReadBinary(uint8_t card, uint16_t offset, uint8_t buf[], uint8_t len);
int Card_ReadBinary0(uint8_t card, uint16_t offset, uint8_t buf[], uint8_t len);

//读记录文件
int Card_ReadRecord(uint8_t card, uint8_t rid, uint8_t record[], uint8_t len);
//更新二进制文件
int Card_UpdateBinary(uint8_t card, uint16_t offset, uint8_t buf[], uint8_t len);
int Card_UpdateBinary0(uint8_t card, uint16_t offset, uint8_t buf[], uint8_t len);

//更新记录
int Card_UpdateRecord(uint8_t card, uint8_t rid, uint8_t p2, uint8_t record[], uint8_t len);

//追加记录
int Card_AppendRecord(uint8_t card, uint8_t rid, uint8_t record[], uint8_t len);


int Card_ReadBinaryFile(uint8_t card, uint16_t fid, uint16_t offset, uint8_t buf[], uint8_t len);
int Card_ReadBinaryFile0(uint8_t card, uint16_t fid, uint16_t offset, uint8_t buf[], uint8_t len);


int Card_WriteBinaryFile(uint8_t card, uint16_t fid, uint16_t offset, uint8_t buf[], uint8_t len);
int Card_WriteBinaryFile0(uint8_t card, uint16_t fid, uint16_t offset, uint8_t buf[], uint8_t len);

int Card_ReadRecordFile(uint8_t card, uint16_t fid, uint8_t rid, uint8_t record[], uint8_t len);

int Card_WriteRecordFile(uint8_t card, uint16_t fid, uint8_t record[], uint8_t len);

int Card_AppendRecordFile(uint8_t card, uint16_t fid, uint8_t record[], uint8_t len);


#endif



